-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix/browser autofill crash #4492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Himmelschmidt
wants to merge
11
commits into
DioxusLabs:main
Choose a base branch
from
Himmelschmidt:fix/browser-autofill-crash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix/browser autofill crash #4492
Himmelschmidt
wants to merge
11
commits into
DioxusLabs:main
from
Himmelschmidt:fix/browser-autofill-crash
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Browser autofill can cause multiple events to fire in rapid succession, leading to nested RefCell borrows in the event handling system. This resulted in 'already borrowed: BorrowMutError' crashes. The root cause was that event handlers were called while RefCells for 'elements' and 'mounts' were still borrowed. When handlers modified the DOM, they would try to borrow the same RefCells again, causing panics. Fixed by restructuring event handling to: 1. Collect all necessary data (listeners, paths) while holding borrows 2. Drop all RefCell borrows before calling any event handlers 3. Execute handlers without any active borrows This eliminates borrow conflicts while maintaining performance - cloning AttributeValue::Listener is cheap as it only increments Rc counters. Also added defensive try_borrow_mut() handling in ListenerCallback::call() as additional safety for edge cases. Fixes browser autofill crashes across all supported browsers.
Browser autofill can dispatch synthetic keyboard events where modifier keys (altKey, ctrlKey, etc.) have undefined values instead of booleans. This causes WASM binding errors when the undefined values are passed to Rust. Added serde(default) attributes to all modifier key fields in SerializedKeyboardData to gracefully handle undefined values by defaulting them to false. This fixes the 'expected a boolean argument, found undefined' errors that occur during browser autofill scenarios.
Browser autofill can send keyboard, mouse, touch, and pointer events with undefined modifier key properties (altKey, ctrlKey, metaKey, shiftKey). This causes wasm-bindgen to throw "expected a boolean argument, found undefined" errors when these events are serialized. Added null coalescing operators (?? false) to all event serialization functions to ensure modifier keys default to false when undefined. Fixes browser autofill crashes in WASM applications.
Compiled TypeScript files to JavaScript using Bun after adding null coalescing operators to handle undefined modifier keys in event serialization. This completes the fix for browser autofill crashes by ensuring both the Rust serde side and JavaScript serialization side handle undefined modifier keys properly.
Browser autofill can send events with undefined modifier key properties (altKey, ctrlKey, metaKey, shiftKey) and undefined string properties (key, code). This causes wasm-bindgen to throw type assertion errors. Added defensive property access using wasm_bindgen::JsValue conversion with appropriate defaults: - Boolean modifier keys default to false when undefined - String properties default to "Unidentified" when undefined This prevents "expected a boolean argument, found undefined" and "expected a string argument, found undefined" errors during browser autofill events. Fixed in all event types that access modifier keys: - KeyboardEvent, MouseEvent, WheelEvent, TouchEvent, DragEvent, PointerEvent
Added defensive null coalescing for KeyboardEvent key and code properties in the TypeScript serialization layer. Browser autofill can send undefined values for these properties, which was causing wasm-bindgen assertion errors.
Additional fixes for handling undefined properties in browser autofill events.
…rsions - Add Default implementations for all event data types to handle browser autofill crashes gracefully - Use specific ClipboardEvent type instead of generic Event for consistency - Remove general unchecked_convert macro that was creating unnecessary unsafe conversions - Keep safe conversions using dyn_into with fallback to default values - Improve type consistency across all event converters This ensures the browser autofill crash is properly handled while making the codebase safer by removing unnecessary unchecked type conversions.
jkelleyrtp
reviewed
Jul 30, 2025
This reverts commit f72d9b2.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BorrowMutError
during rapid event firing (like browser autofill)RefCell
borrows before calling handlerstry_borrow_mut()
inListenerCallback
for edge casesserializeEvent()
dyn_into
and fallback to default valuesunchecked_into
conversionsClipboardEvent
use specific type instead of genericEvent
EmptyEvent
type as fallback for malformed events#[serde(default)]
to modifier keys inSerializedPointInteraction
Per my testing this seems to fix #4486